package dao;

import interfaces.IDaoAluno;
import modelos.Aluno;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import util.Conexao;

public class DaoAluno extends DaoGenerico<Aluno> implements IDaoAluno {

	public DaoAluno() {
	}
	
	public Aluno getPorId(int id) 
	{
		Session session = this.getSession();
		Criteria criteria = session.createCriteria(Aluno.class);
		criteria.add(Restrictions.eq("id", id));
		Aluno a = (Aluno) criteria.uniqueResult();
		session.close();
		return a;
	}
	
	public Aluno getPorCpf(String cpf) {
		Session session = this.getSession();
		Criteria criteria = session.createCriteria(Aluno.class);
		criteria.add(Restrictions.eq("cpf", cpf));
		Aluno a = (Aluno) criteria.uniqueResult();
		session.close();
		return a;
	}
	
	public Aluno getPorMatricula(int matricula) {
		Session session = this.getSession();
		Criteria criteria = session.createCriteria(Aluno.class);
		criteria.add(Restrictions.eq("matricula", matricula));
		Aluno a = (Aluno) criteria.uniqueResult();
		session.close();
		return a;
	}

}
